package router

import (
	"gitee.com/crack007/goose/core/web"
	"github.com/crack007/go-im/src/module/api/controller"
	"github.com/crack007/go-im/src/module/api/middleware"
)

var node = &controller.NodeController{}
var message = &controller.MessageController{}
var user = &controller.UserController{}
var contact = &controller.ContactController{}

func ApiV1(httpServer *web.HttpServer) {
	group := httpServer.Engine.Group("/v1")
	group.Use(middleware.AuthMiddleware, web.JsonMiddleware)

	group.GET("/node/list", web.Action(node.ListNode))
	group.POST("/msg/publish", web.Action(message.Publish))
	group.GET("/msg/list", web.Action(message.ListMessage))
	group.GET("/contact/list", web.Action(contact.List))
	group.GET("/search", web.Action(user.Search))
	group.POST("/addFriend", web.Action(user.AddFriend))
	group.GET("/listFriendApply", web.Action(user.ListFriendApply))
	group.POST("/friendApplyProcess", web.Action(user.FriendApplyProcess))

	apiGroup := httpServer.Engine.Group("/api")
	apiGroup.Use(web.JsonMiddleware)
	apiGroup.POST("/login", web.Action(user.Login))
	apiGroup.POST("/register", web.Action(user.Register))
}
